package com.lizhongbao.cloud.biz.service;

import com.alibaba.fastjson.JSONObject;
import com.lizhongbao.cloud.biz.domain.dto.TestDto;
import com.lizhongbao.cloud.biz.domain.dto.TestQueryDto;
import com.lizhongbao.cloud.biz.domain.eo.Test;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 测试 API
 *
 * @Author lizhongbao
 * @Date 2019/12/23
 */
public interface BizApi {

    String API_PATH = "/api/v1/biz";

    /**
     * 列表-分页查询
     *
     * @param dto
     * @param page
     * @param size
     * @return
     */
    @GetMapping(value = API_PATH)
    JSONObject page(TestQueryDto dto,
                    @RequestParam(name = "page", required = false, defaultValue = "1") Long page,
                    @RequestParam(name = "size", required = false, defaultValue = "10") Long size);

    /**
     * 列表-全部查询
     *
     * @param dto
     * @return
     */
    @GetMapping(value = API_PATH + "/list")
    JSONObject list(TestQueryDto dto);

    /**
     * 详情
     *
     * @param id
     * @return
     */
    @GetMapping(value = API_PATH + "/{id}")
    Test detail(@PathVariable Long id);

    /**
     * 新增
     *
     * @param dto
     * @return
     */
    @PostMapping(value = API_PATH)
    Boolean create(@RequestBody @Valid TestDto dto);

    /**
     * 编辑
     *
     * @param id
     * @param dto
     * @return
     */
    @PutMapping(value = API_PATH + "/{id}")
    Boolean update(@PathVariable Long id, @RequestBody @Valid TestDto dto);

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @DeleteMapping(value = API_PATH + "/{id}")
    Boolean delete(@PathVariable Long id);

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @DeleteMapping(value = API_PATH)
    Boolean delete(@RequestParam("id") Long[] ids);

}

